<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {
            width: 200px;
            height: 200px;
            background-color: pink;
            padding: 10px;
        }
    </style>
</head>
<body>
    <div class="box" style="width: 220px;"></div>
    <script>
        var div = document.querySelector('div');
        console.log(div.offsetWidth);
        console.log(div.style.width);
        /*
                        读写          返回值
        style.width   可读可写       带单位的字符串    行内样式   只有width
        offsetWidth     只读         number          任意样式    width + border + padding

        offsetWidth  用于读取 width
        style.width  用于写
        */
    //    div.style.width = '500px';
       div.offsetWidth = 500;
    </script>
</body>
</html>